package formBean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class LoginForm extends FormBean{
	private String email;
	private String password;

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getPassword()  { 
		return password; 
	}
	
	public void setPassword(String s) {	
		password = s.trim();                  
	}

	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();

		if (email == null || email.length() == 0) {
			errors.add("User Name is required");
		}else{
			if(!email.contains("@") || !email.contains(".") || email.length() < 5){
				errors.add("invalid email format");
			}
			
			if(email.contains("<") || email.contains(">") || email.contains("'") || email.contains("\"") || email.contains("//")){
				errors.add("invalid email format");
			}
		}
		
		if (password == null || password.length() == 0) {
			errors.add("Password is required");
		}else{
			if(password.contains("<") || password.contains(">") || password.contains("'") || password.contains("\"") || password.contains("//")){
				errors.add("invalid password format");
			}
		}
		
		return errors;
	}
}
